package com.example.myapp.fragment;

import org.json.JSONException;
import org.json.JSONObject;

import com.example.myapp.R;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class SettingFragment extends Fragment {
	ImageLoader imageLoader=null;
	View view = null;
	String info;
	ImageView iv_setting;
	TextView tv_setting_name;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		view = inflater.inflate(R.layout.fragment_setting, container, false);
		initView();
		return view;
	}
	private void initView() {
		// TODO Auto-generated method stub
        Bundle bundle = getArguments();//从activity传过来的Bundle
        info=bundle.getString("info");
        iv_setting=(ImageView) view.findViewById(R.id.iv_setting);
        tv_setting_name=(TextView) view.findViewById(R.id.tv_setting_name);
        getJson();
	}
    private void getJson(){
		imageLoader = ImageLoader.getInstance();
    	try {
			JSONObject jsonObject=new JSONObject(info);
			String url=jsonObject.getString("figureurl_qq_2");
			String name=jsonObject.getString("nickname");
			tv_setting_name.setText(name);
			imageLoader.displayImage(url, iv_setting);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
}
